


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > Bill</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/idea.min.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.min.js"></script>
  <script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">item</a>
</div>

<h1>Coverage Summary for Class: Bill (item)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">Bill</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (3/3)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    78.6%
  </span>
  <span class="absValue">
    (33/42)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package item;
&nbsp;
&nbsp;import java.text.ParseException;
&nbsp;import java.text.SimpleDateFormat;
&nbsp;import java.util.Calendar;
&nbsp;import java.util.Date;
&nbsp;
<b class="fc">&nbsp;public class Bill {</b>
&nbsp;    public Date startT;
&nbsp;    public Date endT;
&nbsp;
&nbsp;    public Date StrToDate(String str) {
<b class="fc">&nbsp;        SimpleDateFormat format = new SimpleDateFormat(&quot;yyyyMMddHHmmss&quot;);</b>
<b class="fc">&nbsp;        Date date = null;</b>
&nbsp;        try {
<b class="fc">&nbsp;            date = format.parse(str);</b>
<b class="nc">&nbsp;        } catch (ParseException e) {</b>
<b class="nc">&nbsp;            e.printStackTrace();</b>
<b class="fc">&nbsp;        }</b>
<b class="fc">&nbsp;        return date;</b>
&nbsp;    }
&nbsp;
&nbsp;
&nbsp;    public String getBill(String startingTime, String endingTime) {
<b class="fc">&nbsp;        this.startT = StrToDate(startingTime);</b>
<b class="fc">&nbsp;        this.endT = StrToDate(endingTime);</b>
&nbsp;
&nbsp;        long between;
<b class="fc">&nbsp;        Calendar cal1 = Calendar.getInstance();</b>
<b class="fc">&nbsp;        cal1.setTime(startT);</b>
<b class="fc">&nbsp;        Calendar cal2 = Calendar.getInstance();</b>
<b class="fc">&nbsp;        cal2.setTime(endT);</b>
&nbsp;
<b class="fc">&nbsp;        between = cal2.getTime().getTime() - cal1.getTime().getTime();</b>
&nbsp;        long minute;
<b class="fc">&nbsp;        if (between &lt; 0)</b>
<b class="fc">&nbsp;            minute = ((cal2.getTime().getTime() - cal1.getTime().getTime()) / 1000) / 60;//得到通话时长</b>
&nbsp;        else
<b class="fc">&nbsp;            minute = (between / 1000 + 59) / 60;</b>
&nbsp;
<b class="fc">&nbsp;        if (cal1.get(Calendar.MONTH) == Calendar.MARCH &amp;&amp; cal1.get(Calendar.DATE) &gt;= 29 &amp;&amp; cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal1.get(Calendar.MONTH) == Calendar.APRIL &amp;&amp; cal1.get(Calendar.DATE) &lt;= 4 &amp;&amp; cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {</b>
<b class="fc">&nbsp;            System.out.println(&quot;需要转换1&quot;);</b>
<b class="fc">&nbsp;            if (cal1.get(Calendar.HOUR_OF_DAY) &lt; 2 &amp;&amp; cal2.get(Calendar.HOUR_OF_DAY) &gt;= 3)</b>
<b class="fc">&nbsp;                minute -= 60;</b>
&nbsp;        } else {
<b class="fc">&nbsp;            if (cal2.get(Calendar.MONTH) == 3 &amp;&amp; cal2.get(Calendar.DATE) &gt;= 29 &amp;&amp; cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal2.get(Calendar.MONTH) == 4 &amp;&amp; cal2.get(Calendar.DATE) &lt;= 4 &amp;&amp; cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {</b>
<b class="nc">&nbsp;                if (cal2.get(Calendar.HOUR_OF_DAY) &gt; 3)</b>
<b class="nc">&nbsp;                    minute -= 60;</b>
&nbsp;            }
&nbsp;        }
&nbsp;
<b class="fc">&nbsp;        if (cal1.get(Calendar.MONTH) == Calendar.OCTOBER &amp;&amp; cal1.get(Calendar.DATE) &gt;= 25 &amp;&amp; cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {</b>
<b class="fc">&nbsp;            if (cal1.get(Calendar.HOUR_OF_DAY) == 2) {</b>
<b class="fc">&nbsp;                minute += 60;</b>
&nbsp;            }
&nbsp;        } else {
<b class="fc">&nbsp;            if (cal2.get(Calendar.MONTH) == Calendar.OCTOBER &amp;&amp; cal2.get(Calendar.DATE) &gt;= 25) {</b>
<b class="nc">&nbsp;                cal2.get(Calendar.DATE);</b>
<b class="nc">&nbsp;                if (cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {</b>
<b class="nc">&nbsp;                    if (cal2.get(Calendar.HOUR_OF_DAY) == 2) {</b>
<b class="nc">&nbsp;                        minute += 60;</b>
&nbsp;                    }
&nbsp;                }
&nbsp;            }
&nbsp;        }
<b class="fc">&nbsp;        if (minute &gt; 1800 || minute &lt; 0) {</b>
<b class="nc">&nbsp;            return &quot;输入错误,没有超过30个小时的通话&quot;;</b>
&nbsp;        } else {
<b class="fc">&nbsp;            double fare = 0;</b>
<b class="fc">&nbsp;            if (minute &lt;= 20)</b>
<b class="fc">&nbsp;                fare = (minute * 0.05);</b>
&nbsp;            else
<b class="fc">&nbsp;                fare = 1 + (minute - 20) * 0.1;</b>
<b class="fc">&nbsp;            System.out.println(&quot;通话时间为：&quot; + minute + &quot;分钟&quot;);</b>
<b class="fc">&nbsp;            System.out.println(&quot;本次通话话费为：&quot; + fare + &quot;美元&quot;);</b>
<b class="fc">&nbsp;            return String.format(&quot;%.2f&quot;, fare);</b>
&nbsp;        }
&nbsp;
&nbsp;    }
&nbsp;}
&nbsp;
</code>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
      hljs.highlightAll()
      hljs.initLineNumbersOnLoad();
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2023-04-08 21:16</div>
</div>
</body>
</html>
